﻿using Microsoft.Playwright;
using StoreTools.Common;
using StoreTools.Online.Base;
using System;
using System.Threading.Tasks;
using StoreTools.Tools;

namespace StoreTools.Online.Pinduoduo
{
    public class PinDuoDuoPlayer : Player
    {
        public PinDuoDuoPlayer(PlayerTask playerTask, ExecuteStatus status) : base(playerTask, status) { }

        public override async Task Execute(IBrowser browser)
        {
            try
            {
                await new PinDuoDuoReceiver(this).Execute(browser);
            }
            catch (System.Exception e)
            {
                await Console.Out.WriteLineAsync(e.Message);
            }
            finally
            {
                ParseFile.WriteListToFile(this.TitlePath, this.TitleList);
            }
        }
    }

}
